package com.baeldung.bidirect;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by dzy on 2018/9/1
 */
public class User {
  public int id;
  public String name;

  @JsonBackReference
  //是引用的后半部分 - 它将从序列化中省略
  public List<Item> userItems = new ArrayList<>();

  public User(int id, String name) {
    this.id = id;
    this.name = name;
  }

  public void addItem(Item item) {
    userItems.add(item);
  }
}
